package com.bjsxt.userscenter.common.util;

import java.util.Map;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.stereotype.Component;

/**
 * 正则表达式
 * @author wangshSxt
 *
 */
@Component
public class RegexUtil
{
	
	/* 正则表达式 */
	private String pattern_$ = "(\\$\\{)(\\w+)(\\})";
	/**
	 * 生成随机数
	 * @param length	指定长度
	 * @return	返回随机数
	 */
	
	public static void main(String[] args)
	{
		RegexUtil re = new RegexUtil();
		re.proccedStr(4);
	}
	
	public String proccedStr(int length)
	{
		StringBuffer sb = new StringBuffer();
		Random random = new Random();
		for(int i = 0 ; i < length ; i ++)
		{
			int randInt = random.nextInt(ConstatFinalUtil.ALLSTR.length());
			char ch = ConstatFinalUtil.ALLSTR.charAt(randInt);
			System.out.println(randInt+"------->"+ch);
			
			sb.append(ch);
		}
		return sb.toString() ; 
	}
	
	public String replace$(String souStr,Map<String,String> condmap)
	{
		StringBuffer sb = new StringBuffer();
		Pattern pattern = Pattern.compile(pattern_$);
		Matcher mather = pattern.matcher(souStr);
		boolean falg = mather.matches();
		ConstatFinalUtil.LOGGER.info("falg:{}",falg);
		
		
		return souStr;
		
	}
	
	
	
}
